package com.csliubo.eclipse.plugin.sqlgenerator.core.model;

import java.util.ArrayList;
import java.util.List;

import com.csliubo.eclipse.plugin.sqlgenerator.util.StringUtils;

public class Row {

    private static final String EMPTY_STR = " ";
    List<String>                columns;

    public Row() {
        columns = new ArrayList<String>();
    }

    public void addColumn(String column) {
        columns.add(column);
    }
    public int getColumnNum(){
        return columns.size();
    }
    public List<String> getColumns() {
        return columns;
    }

    @Override
    public String toString() {
        return toString(" ");
    }

    public String toString(String separator) {
        StringBuilder sb = new StringBuilder();
        for (String str : columns) {
            if (StringUtils.isBlank(str)) {
                str = EMPTY_STR;
            }
            sb.append(str).append(separator);
        }
        if (sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }
}
